//src/user/index.js

import service from "./request.js";

export function LoginInfo(query) {
  return service({
    method: "get",
    url: "/multi_account/login/"+query.username+"/"+query.password,
  });
}
export function getMenuList(query) {
  return service({
    method: "get",
    url: "/permission/getMenuList",
    // url: "/api/permission/getMenuList",
    data: query,
  });
}

export function getUserList(query) {
  return service({
    method: "get",
    url: "/permission/UserList",
    data: query,
  });
}
export function addUserList(query) {
  return service({
    method: "post",
    url: "/permission/addUserList",
    data: query,
  });
}
export function listUpdate(query) {
  return service({
    method: "post",
    url: "/permission/listUpdate",
    data: query,
  });
}
export function homeList(query) {
  return service({
    method: "get",
    url: "/permission/homeList",
    data: query,
  });
}
export function noticeLists(query) {
  return service({
    method: "get",
    // url: "/permission/noticeLists",
    url: "/api/permission/noticeLists",
    data: query,
  });
}




// 获取合约账户余额
export const getDeliveryAccountBalances = async () => {
  
  return service({
    method: "get",
    url: "/gateio/delivery_account_balances",
    data: query,
  })
};




// 查询现货账户余额
export const getSpotAccountBalances = async () => {
  return service({
    method: "get",
    url: "/gateio/spot_account_balances"
  });
};


// 获取指定账户的钱包余额
export const getWalletBalance = async (accountName) => {
  return service({
    method: "get",
    url: `/wallet/get_wallet_balance?account_name=${accountName}`
  });
};


// 获取所有账户的钱包余额
export const getWalletBalances = async () => {
  return service({
    method: "get",
    url: "/wallet/get_wallet_balances"
  });
};

// 获取指定账户的交易记录
export const getTradeRecords = async (params) => {
  return service({
    method: "post",
    url: "/trade/get_trade_records",
    data: params
  });
};


// 获取所有账户的交易记录
export const getAllTradeRecords = async (params) => {
  return service({
    method: "post",
    url: "/trade/get_all_trade_records",
    data: params
  });
};


// 平仓操作
export const closePosition = async (data) => {
  return service({
    method: "post",
    url: "/multi_account/close_position",
    data: data
  });
};


// 开仓操作
export const createOrder = async (data) => {
  return service({
    method: "post",
    url: "/multi_account/create_order",
    data: data
  });
};


// 返回所有账号信息
export function getAllAccount(query) {
  return service({
    method: "get",
    url: "/multi_account/accounts",
    data: query,
  });
}

// 根据ID返回单个账户详细信息
export function getAccountById(id) {
  return service({
    method: "get",
    url: "/multi_account/accounts/"+id,
  });
}

// 根据密钥获取用户持有仓位信息
export function getAccountPositions(query) {
  return service({
    method: "get",
    url: "/gateio/user_positions",
    params: query,
  });
}

// 创建订单
export function createOrderv2(query) {
  return service({
    method: "post",
    url: "/trading_ns/create_order",
    data: query,
  });
}

// 获取当个合约的相关信息
export function getFuturesInfosigle(query) {
  return service({
    method: "get",
    url: "/gateio/get_one_futures_contract",
    params: query,
  });
}

// 查询所有合约交易行情统计
export function getAllFuturesTickers(query){
  return service({
    method: "get",
    url: "/gateio/futures_tickers",
    params:query
  });
};

// 查询合约账户余额
export function getFuturesAccountBalances(query){
  return service({
    method: "get",
    url: "/gateio/futures_account",
    params:query
  });
};
// 登录接口
export function Login(query) {
  return service({
    method: "get",
    url: "/multi_account/login/"+query.name+"/"+query.password,
  });
}

// 获取编队账号
export function getTeamAccount(query) {
  return service({
    method: "get",
    url: "/multi_account/accounts/search",
    params: query,
  });
}

// 删除账号
export function delTeamAccount(query) {
  return service({
    method: "delete",
    url: "/multi_account/accounts/del/"+query,
  });
}

// 添加账号
export function addTeamAccount(query) {
  return service({
    method: "post",
    url: "/multi_account/accounts/add",
    data: query,
  });
}

// 更新账户信息
export function updateTeamAccount(id,query) {
  return service({
    method: "put",
    url: "/multi_account/accounts/updata/"+id,
    data: query,
  });
}

// 交易记录查询
export function getTradeRecordsv2(query) {
  return service({
    method: "post",
    url: "/trading_ns/personal_trading_history",
    data: query,
  });
}

// 未完成交易价列表
export function getUnfinishedTradeRecordsv2(query) {
  return service({
    method: "get",
    url: "/gateio/futures_orders",
    params: query,
  });
}

// 取消订单
export function cancelOrder(id,query) {
  return service({
    method: "delete",
    url: "/trading_ns/cancel_order/"+id,
    params: query,
  });
}


// 设置仓位模式
export function settingposition(query) {
  return service({
    method: "post",
    url: "/multi_account/control_position_mode",
    data: query,
  });
}